package com.elink.enginerring.file;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.elink.enginerring.common.BaseCo;
import com.elink.enginerring.datasource.DataSourceContextHolder;
import com.elink.enginerring.datasource.DataSourceType;
import com.elink.enginerring.video.entity.SkillFile;
import com.elink.enginerring.video.service.ISkillService;

/**
 * 建筑类别体系
 * @author hxjxiaojun
 *@time 2016年12月11日
 */
@Controller
@RequestMapping("/view/build")
@Api(value="建筑类别体系接口")
public class BuildController {
	@Autowired
	private ISkillService  skillService;

	/**
	 * 分页获取建筑类别体系
	 * @return
	 */
	@RequestMapping(value = "/getList", method = RequestMethod.GET)
	@ApiOperation(value = "获取建筑类别体系", httpMethod = "GET",  notes = "分页获取建筑类别体系")
	@ResponseBody
	public Map<String, Object>getList(@ModelAttribute @Valid BaseCo co ){
		DataSourceContextHolder.setDbType(DataSourceType.DBSKILL);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType()); 
		return skillService.getList(co);
	}

	/**
	 * 增加建筑类别体系--资料
	 * @param skillFile
	 * @return
	 */
	@RequestMapping(value = "/addFile", method = RequestMethod.POST)
	@ApiOperation(value = "增加建筑类别体系--资料", httpMethod = "POST",  notes = "增加建筑类别体系--资料")
	@ResponseBody
	public Map<String, Object>addFile(@ModelAttribute @Valid SkillFile skillFile){
		DataSourceContextHolder.setDbType(DataSourceType.DBSKILL);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType()); 
		return skillService.addFile(skillFile);
	}
	
	/**
	 * 获取建筑类别体系分类
	 * @param skill
	 * @return
	 */
	@RequestMapping(value = "/getCategory", method = RequestMethod.GET)
	@ApiOperation(value = "获取建筑类别体系分类", httpMethod = "GET",  notes = "获取建筑类别体系分类")
	@ResponseBody
	public Map<String, Object>getCategory(){
		DataSourceContextHolder.setDbType(DataSourceType.DBSKILL);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType()); 
		return skillService.getCategory();
	}
}
